/*
 * @Author: wuzhouhai wzh200x@126.com
 * @Date: 2024-03-20 16:32:52
 * @LastEditors: wzh200x@126.com
 * @LastEditTime: 2025-08-21 12:00:31
 * @FilePath: \dwys_web\extensions\phoenix-plugin-client\assets\core\defines\error.define.ts
 * @Description: 
 */
export enum ErrorCode {
    UNKNOWN_ERROR = 10000,
    ACCOUNT_ERROR,
    ACCOUNT_PASSWORD,
    ACCOUNT_NOT_FOUND,
    TOKEN_NULL,
    TOKEN_INVALID,
    TOKEN_ILLEGAL,
    AVATAR_ALREADY_EXIST,
    AVATAR_NOT_FOUND,
    REQUEST_PARAM_SIGNATURE,
    REQUEST_PARAM_TIME,
    PLATFORM_LOGIN_FAILED,
    ACCOUNT_NAME_NOT_MATCH,
    CDKEY_HAS_EXIST,
    CDKEY_NOT_EXIST,
    CDKEY_USED_OVER,
    CDKEY_LIMIT_OVER,
    CDKEY_HAS_USED,
    CDKEY_GROUP_NOT_EXIST,
    PLATFORM_ERROR,
    ORDER_STATUS_ERROR,
    ORDER_NOT_FOUND,
    CARD_CONFIG_NOT_FOUND,
    CARD_GROUP_NOT_FOUND,
    CARD_CHOOSE_TIMES_ERROR
}

export enum ErrorCodeDescription {
    UNKNOWN_ERROR = '未知错误',
    ACCOUNT_ERROR = '账号错误',
    ACCOUNT_PASSWORD = '密码错误',
    ACCOUNT_NOT_FOUND = '账号不存在',
    TOKEN_NULL = 'token为空',
    TOKEN_INVALID = 'token无效',
    TOKEN_ILLEGAL = 'token非法',
    AVATAR_ALREADY_EXIST = '角色已存在',
    AVATAR_NOT_FOUND = '角色不存在',
    REQUEST_PARAM_SIGNATURE = '请求参数签名错误',
    REQUEST_PARAM_TIME = '请求参数时间错误',
    PLATFORM_LOGIN_FAILED = '平台登录失败',
    ACCOUNT_NAME_NOT_MATCH = '账号与角色不匹配',
    CDKEY_HAS_EXIST = '礼包码已存在',
    CDKEY_NOT_EXIST = '礼包码不存在',
    CDKEY_USED_OVER = '礼包码次数已经用完',
    CDKEY_LIMIT_OVER = '礼包码使用期限到期',
    CDKEY_HAS_USED = '已使用过同类礼包码',
    CDKEY_GROUP_NOT_EXIST = '礼包不存在',
    PLATFORM_ERROR = '平台错误',
    ORDER_STATUS_ERROR = '订单状态错误',
    ORDER_NOT_FOUND = '订单不存在',
    CARD_CONFIG_NOT_FOUND = '抽卡配置不存在',
    CARD_GROUP_NOT_FOUND = '抽卡组不存在',
    CARD_CHOOSE_TIMES_ERROR = '抽卡次数错误',
}

export function makeError(errorCode: ErrorCode, errorDescription?: ErrorCodeDescription): object {
    return { "message": errorDescription, "code": errorCode };
}

export function getErrorDescription(errorCode: ErrorCode): ErrorCodeDescription {
    switch (errorCode) {
        case ErrorCode.ACCOUNT_ERROR:
            return ErrorCodeDescription.ACCOUNT_ERROR;
        case ErrorCode.ACCOUNT_PASSWORD:
            return ErrorCodeDescription.ACCOUNT_PASSWORD;
        case ErrorCode.ACCOUNT_NOT_FOUND:
            return ErrorCodeDescription.ACCOUNT_NOT_FOUND;
        case ErrorCode.TOKEN_NULL:
            return ErrorCodeDescription.TOKEN_NULL;
        case ErrorCode.TOKEN_INVALID:
            return ErrorCodeDescription.TOKEN_INVALID;
        case ErrorCode.TOKEN_ILLEGAL:
            return ErrorCodeDescription.TOKEN_ILLEGAL;
        case ErrorCode.AVATAR_ALREADY_EXIST:
            return ErrorCodeDescription.AVATAR_ALREADY_EXIST;
        case ErrorCode.AVATAR_NOT_FOUND:
            return ErrorCodeDescription.AVATAR_NOT_FOUND;
        case ErrorCode.REQUEST_PARAM_SIGNATURE:
            return ErrorCodeDescription.REQUEST_PARAM_SIGNATURE;
        case ErrorCode.REQUEST_PARAM_TIME:
            return ErrorCodeDescription.REQUEST_PARAM_TIME;
        case ErrorCode.PLATFORM_LOGIN_FAILED:
            return ErrorCodeDescription.PLATFORM_LOGIN_FAILED;
        case ErrorCode.ACCOUNT_NAME_NOT_MATCH:
            return ErrorCodeDescription.ACCOUNT_NAME_NOT_MATCH;
        case ErrorCode.CDKEY_HAS_EXIST:
            return ErrorCodeDescription.CDKEY_HAS_EXIST;
        case ErrorCode.CDKEY_NOT_EXIST:
            return ErrorCodeDescription.CDKEY_NOT_EXIST;
        case ErrorCode.CDKEY_USED_OVER:
            return ErrorCodeDescription.CDKEY_USED_OVER;
        case ErrorCode.CDKEY_LIMIT_OVER:
            return ErrorCodeDescription.CDKEY_LIMIT_OVER;
        case ErrorCode.CDKEY_HAS_USED:
            return ErrorCodeDescription.CDKEY_HAS_USED;
        case ErrorCode.CDKEY_GROUP_NOT_EXIST:
            return ErrorCodeDescription.CDKEY_GROUP_NOT_EXIST;
        case ErrorCode.PLATFORM_ERROR:
            return ErrorCodeDescription.PLATFORM_ERROR;
        case ErrorCode.ORDER_STATUS_ERROR:
            return ErrorCodeDescription.ORDER_STATUS_ERROR;
        case ErrorCode.ORDER_NOT_FOUND:
            return ErrorCodeDescription.ORDER_NOT_FOUND;    
        case ErrorCode.CARD_CONFIG_NOT_FOUND:
            return ErrorCodeDescription.CARD_CONFIG_NOT_FOUND;
        case ErrorCode.CARD_GROUP_NOT_FOUND:
            return ErrorCodeDescription.CARD_GROUP_NOT_FOUND;
        case ErrorCode.CARD_CHOOSE_TIMES_ERROR:
            return ErrorCodeDescription.CARD_CHOOSE_TIMES_ERROR;
        default:
            return ErrorCodeDescription.ACCOUNT_ERROR;
    }
}
